describe('App.BaseAccount', function() {
    it('getTransferProductVO', function() {
        var account = App.BaseAccount.create({
            "accountNumber": "30606620475",
            "currencyCode": "IDR",
            "productCategory": "CASA"
        });

        expect(JSON.stringify(account.getTransferProductVO())).toEqual(JSON.stringify({
            "accountNumber": "30606620475",
            "currencyCode": "IDR",
            "productCategory": "CASA"
        }));
    });
});

describe('App.HaveAccount', function() {
    it('name', function() {
        var name = 'account name';
        var account = App.HaveAccount.create({
            accountType: name
        });

        expect(account.get('name')).toEqual(name);
    });

    describe('displayableObject', function() {
        it('displayableObject', function() {
            var account = App.HaveAccount.create({
                "accountName": "XXXX",
                "accountNumber": "30606620475",
                "accountType": "Currenct Account-Foreign Currency",
                "currencyCode": "USD",
                "productCategory": "CASA",
                "currentBalance": 14025.53,
                "availableBalance": 14025.53,
                "lineAmount": 0,
                "accKey": "30606620475:USD"
            });

            var expectedOutput = [
                {
                    "value": [
                        {
                            "key": "Account Name",
                            "value": "XXXX"
                        },
                        {
                            "key": "Account Number",
                            "value": "30606620475"
                        },
                        {
                            "key": "Account Type",
                            "value": "Currenct Account-Foreign Currency"
                        },
                        {
                            "key": "Available Balance",
                            "value": {
                                "currencyCode": "USD",
                                "amount": 14025.53
                            },
                            "isAmount": true,
                            "isNegative": false
                        },
                        {
                            "key": "Current Balance",
                            "value": {
                                "currencyCode": "USD",
                                "amount": 14025.53
                            },
                            "isAmount": true,
                            "isNegative": false
                        }
                    ]
                }
            ];

            expect(JSON.stringify(account.get('displayableObject'))).toEqual(JSON.stringify(expectedOutput));
        });
    });
});

describe('App.LoanAccount', function() {
    it('name', function() {
        var name = 'account name';
        var loan = App.LoanAccount.create({
            accountType: name
        });

        expect(loan.get('name')).toEqual(name);
    });

    it('displayableObject', function() {
        var loan = App.LoanAccount.create({
            "accountNumber": "6543367",
            "accountType": "HOUSING LOAN-RB",
            "currencyCode": "IDR",
            "currentBalance": 521166666.08,
            "accKey": "6543367:IDR",
            "installmentAmount": 9077313.89,
            "nextDueDate": "2012-04-10T00:00:00.000+0800",
            "maturityDate": "2021-01-10T00:00:00.000+0800",
            "loanTenor": "120",
            "remainingTenor": "106",
            "availableBalance": 12500000
        });

        var expectedOutput = [
            {
                "value": [
                    {
                        "key": "Loan Amount",
                        "value": {
                            "currencyCode": "IDR",
                            "amount": 12500000
                        },
                        "isAmount": true,
                        "isNegative": true
                    },
                    {
                        "key": "Loan Account Number",
                        "value": "6543367"
                    },
                    {
                        "key": "End Date",
                        "value": "2021-01-10"
                    },
                    {
                        "key": "Current Outstanding Amount",
                        "value": {
                            "currencyCode": "IDR",
                            "amount": 521166666.08
                        },
                        "isAmount": true,
                        "isNegative": true
                    },
                    {
                        "key": "Installment Amount",
                        "value": {
                            "currencyCode": "IDR",
                            "amount": 9077313.89
                        },
                        "isAmount": true,
                        "isNegative": true
                    },
                    {
                        "key": "Next Installment",
                        "value": "2012-04-10"
                    },
                    {
                        "key": "No. of Installments to Date",
                        "value": "120"
                    },
                    {
                        "key": "No. of Installments Remaining",
                        "value": "106"
                    },
                    {
                        "key": "Terms"
                    }
                ]
            }
        ];

        expect(JSON.stringify(loan.get('displayableObject'))).toEqual(JSON.stringify(expectedOutput));
    })
});

describe('App.CardAccount', function() {
    it('name', function() {
        var name = 'card name';
        var card = App.CardAccount.create({
            cardType: name
        });

        expect(card.get('name')).toEqual(name);
    });


    describe('displayableObject', function(){
        it('normal card', function() {
            var card = App.CardAccount.create({
                "accountNumber": "4511960210021696",
                "accountType": "CARD",
                "currencyCode": "IDR",
                "productCategory": "CARD",
                "currentBalance": -9450000,
                "cardType": "432",
                "cardStatus": "1",
                "blockCode": "",
                "statementBalance": -94500,
                "minimumAmountDue": 0,
                "accKey": "4511960210021696:IDR",
                "accountStatus": "1",
                "availableCreditLimit": 3000,
                "paymentDate": "2011-12-17T00:00:00.000+0000"
            });

            var expectedOutput = [
                {
                    "value": [
                        {
                            "key": "Card Number",
                            "value": "4511960210021696"
                        },
                        {
                            "key": "Account Type",
                            "value": "432"
                        },
                        {
                            "key": "Total Credit Limit",
                            "value": {
                                "currencyCode": "IDR",
                                "amount": 3000
                            },
                            "isAmount": true,
                            "withoutColorIndicator": true
                        }
                    ]
                },
                {
                    "title": "Latest Statement Details",
                    "value": [
                        {
                            "key": "Statement Balance",
                            "value": {
                                "currencyCode": "IDR",
                                "amount": -94500
                            },
                            "isAmount": true,
                            "isNegative": false
                        },
                        {
                            "key": "Minimum Payment Due",
                            "value": {
                                "currencyCode": "IDR",
                                "amount": 0
                            },
                            "isAmount": true,
                            "isNegative": false
                        },
                        {
                            "key": "Payment Due Date",
                            "value": "Saturday, 17 December 2011"
                        }
                    ]
                }
            ];

            expect(JSON.stringify(card.get('displayableObject'))).toEqual(JSON.stringify(expectedOutput));
        })
    });

    it("getTransferProductVO",function(){
        var account = App.CardAccount.create({
            "accountNumber": "30606620475",
            "currencyCode": "IDR",
            "productCategory": "CASA",
            "productCode":"CC"
        });

        expect(JSON.stringify(account.getTransferProductVO())).toEqual(JSON.stringify({
            "accountNumber": "30606620475",
            "currencyCode": "IDR",
            "productCategory": "CASA",
            "productCode":"CC"
        }));
    });

    it("outStandingBalance",function(){
        var outStandingBalance = 'outStandingBalance';
        var card = App.CardAccount.create({
             "currentBalance":outStandingBalance
        });

        expect(card.get('outStandingBalance')).toEqual(outStandingBalance);
    });


    it("availableCashLimit",function(){
        var availableCashLimit = 'availableCashLimit';
        var card = App.CardAccount.create({
            "availableBalance":availableCashLimit
        });

        expect(card.get('availableCashLimit')).toEqual(availableCashLimit);
    });
});